package com.test;

import com.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class DataInitializer {
    private static final Logger logger = LoggerFactory.getLogger(DataInitializer.class);

    public static void main(String[] args) {
        try {
            // 指定正确的配置文件路径
            ApplicationContext context = new ClassPathXmlApplicationContext(
                    "applicationContext.xml"
            );

            UserService userService = context.getBean(UserService.class);
            userService.initializeUserRemainingData();

            logger.info("用户数据初始化完成");
            System.out.println("用户数据初始化完成");
        } catch (Exception e) {
            logger.error("初始化失败", e);
            e.printStackTrace();
        }
    }
}